import { legacy_createStore, combineReducers } from 'redux'
import { LoadingInfo } from './loadingInfoRedux'
import { UserInfo } from './userInfoRedux'
import { NavExpandInfo } from './navExpandInfo'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
    key: 'joe',//键名
    storage,// 存储引擎，默认使用localStorage
    whitelist: ['UserInfo']//指定需要持久化存储的reducer 白名单
}

const reducers = combineReducers({
    UserInfo,
    NavExpandInfo,
    LoadingInfo
})

const persistedReducer = persistReducer(persistConfig, reducers)

const store = legacy_createStore(persistedReducer)

let persistor = persistStore(store)

export {
    store,
    persistor
}